{
 "metadata": {},
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "wxPython dialogs\n",
      "================\n",
      "\n",
      "Something I enjoy in matlab is the ease in which simple file selector\n",
      "dialogs, and status bars can be made. Now that I use nothing but scipy,\n",
      "I have wanted to have simliar functions for my scipy code. Thanks to the\n",
      "great reference [\"wxPython in Action\"](http://www.manning.com/rappin/) I\n",
      "have learned some of the basics again, with the promise of making very\n",
      "fancy GUIs if I ever find the urge! (Check out the sample chapters, they\n",
      "have given the entire section on making dialogs, which is how I\n",
      "initially got started with wxPython).\n",
      "\n",
      "File Selector Dialog\n",
      "--------------------\n",
      "\n",
      "I often write simple translation scripts that convert some data, into\n",
      "another form. I like to use these for a series of data, and share them\n",
      "with some coworkers who do not program. the wxPython FileSelector\n",
      "function comes to the rescue."
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import wx\n",
      "\n",
      "# setup the GUI main loop\n",
      "app = wx.App()\n",
      "\n",
      "filename = wx.FileSelector()"
     ],
     "language": "python",
     "metadata": {},
     "outputs": []
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "With this basic code, filename contains a string pathname (may be\n",
      "unicode depending on your installation of wxPython, more on this latter)\n",
      "of the selected file.\n",
      "\n",
      "Some of the spiffing up will include using the current directory the\n",
      "script was started in, we do this easily"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import wx\n",
      "import os\n",
      "\n",
      "# setup the GUI main loop\n",
      "app = wx.App()\n",
      "\n",
      "filename = wx.FileSelector(default_path=os.getcwd())"
     ],
     "language": "python",
     "metadata": {},
     "outputs": []
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "If one runs such script repeatedly, it might be a good idea to do some\n",
      "basic clean-up after each run."
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# ...\n",
      "app.Destroy()"
     ],
     "language": "python",
     "metadata": {},
     "outputs": []
    }
   ],
   "metadata": {}
  }
 ]
}